﻿/* 9. Write a program to print the first 100 members of the sequence of Fibonacci: 
 * 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ... */

// Add Reference to 'System.Numerics'.

using System;
using System.Numerics;

public class FibonacciSequence
{
    public static void Main()
    {
        Console.Write("How members of the sequence of Fibonacci do you want to print? : ");
        int members = int.Parse(Console.ReadLine());
        if (members < 1)
            throw new ArgumentException("Enter positive integer!");

        int lastBitOfMembers = ((members | 1) == members ? 1 : 0);
        BigInteger first = 0;
        BigInteger second = 1;
        int steps;

        if (members == 1)
            Console.Write(first);
        else
        {
            Console.Write("{0}, {1}", first, second);
            if (members > 2)
            {
                steps = (members - 2) / 2 + lastBitOfMembers - 1;
                for (int i = 0; i < steps; i++)
                {
                    first += second;
                    second += first;
                    Console.Write(", {0}, {1}", first, second);
                }

                first += second;
                Console.Write(", {0}", first);
                if (lastBitOfMembers == 0)
                {
                    second += first;
                    Console.Write(", {0}", second);
                }
            }
        }

        Console.WriteLine();
    }
}